package com.book.oauth.server.user.hystrix.impl;

import com.book.common.api.helper.LanguageHelper;
import com.book.common.api.impl.BaseHystrixImpl;
import com.book.common.result.Failed;
import com.book.common.result.RestResponse;
import com.book.oauth.server.user.dto.UserDto;
import com.book.oauth.server.user.hystrix.IUserHystrix;
import com.book.oauth.server.user.vo.UserVo;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * Description：用户 HystrixImpl
 *
 * @Author： leo.xiong
 * @CreateDate： 2020-04-26
 * @Email： leo.xiong@suyun360.com
 * @Version:
 */
@Slf4j
@Component
public class UserHystrixImpl extends BaseHystrixImpl<UserDto, UserVo> implements FallbackFactory<IUserHystrix>, IUserHystrix {

    @Override
    public IUserHystrix create(Throwable e) {
        log.error("用户服务调用失败:{}", e.getMessage());
        e.printStackTrace();
        return new UserHystrixImpl();
    }

    /**
     * 修改最后登录时间并保存登录日志信息
     *
     * @param userId
     * @param userName
     * @param location
     * @param ip
     * @param browser
     * @param systemInfo
     * @return
     */
    @Override
    public RestResponse<String> updateLoginTime(String userId, String userName, String location, String ip, String browser, String systemInfo) {
        return new Failed("BOOK:COMMON:10018", "UserHystrixImpl.updateLoginTime" + LanguageHelper.getValue("BOOK:COMMON:10018"));
    }

    /**
     * 根据Id重置密码
     *
     * @param id
     */
    @Override
    public RestResponse<String> resetPassword(Long id) {
        return new Failed("BOOK:COMMON:10018", "UserHystrixImpl.resetPassword" + LanguageHelper.getValue("BOOK:COMMON:10018"));
    }

    /**
     * 修改密码
     *
     * @param id
     * @param oldPassword
     * @param password
     */
    @Override
    public RestResponse<String> updatePassword(Long id, String oldPassword, String password) {
        return new Failed("BOOK:COMMON:10018", "UserHystrixImpl.updatePassword" + LanguageHelper.getValue("BOOK:COMMON:10018"));
    }

    /**
     * 修改头像信息
     *
     * @param id
     * @param avatar
     */
    @Override
    public RestResponse<String> updateAvatar(Long id, String avatar) {
        return new Failed("BOOK:COMMON:10018", "UserHystrixImpl.updatePassword" + LanguageHelper.getValue("BOOK:COMMON:10018"));
    }

    /**
     * 修改主题信息
     *
     * @param id
     * @param theme
     */
    @Override
    public RestResponse<String> updateTheme(Long id, String theme) {
        return new Failed("BOOK:COMMON:10018", "UserHystrixImpl.updateTheme" + LanguageHelper.getValue("BOOK:COMMON:10018"));
    }

    /**
     * 修改tab信息
     *
     * @param id
     * @param isTab
     */
    @Override
    public RestResponse<String> updateTab(Long id, String isTab) {
        return new Failed("BOOK:COMMON:10018", "UserHystrixImpl.updateTab" + LanguageHelper.getValue("BOOK:COMMON:10018"));
    }
}
